package com.tanhua.admin.controller;

import com.tanhua.admin.service.DashboardService;
import com.tanhua.model.vo.GaiYaoVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * @author 夯大力
 * 2021/11/8
 * 14:54
 * 后台管理系统
 */

@RestController
@RequestMapping("/dashboard")
public class DashboardController {
    @Autowired
    private DashboardService dashboardService;

    /**
     * 一段时间内的用户的数量
     *
     * @param sd   开始日期
     * @param ed   结束日期
     * @param type 类型 101 新增 102 活跃用户 103 次日留存率
     */
    @GetMapping("/users")
    public ResponseEntity users(String sd, String ed, String type) {
        Map<String, Object> map = dashboardService.users(sd,ed,type);
        return ResponseEntity.ok(map);
    }

    /**
     * 展示后台用户的概要
     *
     * @return
     */
    @GetMapping("/summary")
    public ResponseEntity summary() {
        GaiYaoVo vo = dashboardService.summary();
        return ResponseEntity.ok(vo);
    }
}
